package web.servlet.request.SorryServlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Author: 18148
 * @Date: 2020-05-16 09:23:41
 */
@WebServlet("/answer")
public class Answer extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("调查问卷数据如下：");
        String username = req.getParameter("username");
        System.out.println("name:"+username);
        String[] sexes = req.getParameterValues("sex");
        System.out.println("sex:"+new String(sexes[0].getBytes(),"utf-8"));
        String[] hobbies = req.getParameterValues("hobby");
        System.out.println("special: ");
        for (int i = 0; i < hobbies.length; i++) {
            System.out.print(hobbies[i]+" ");
        }
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doGet(req, resp);
    }
}
